package com.example.change;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class MyDialogFragment extends DialogFragment {


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
    	String dialogEntry = "";
    	if(getArguments().containsKey((MainActivity.HAS_CASH_KEY))){
    		dialogEntry = getArguments().getString(MainActivity.HAS_CASH_KEY);
    	}else if(getArguments().containsKey((MainActivity.TOO_MANY_DECIMAL_PLACES_KEY))){
    		dialogEntry = getArguments().getString(MainActivity.TOO_MANY_DECIMAL_PLACES_KEY);
    	}else{
    		dialogEntry = getArguments().getString(MainActivity.CASH_IS_EMPTY_KEY);
    	}

        return new AlertDialog.Builder(getActivity())
                .setTitle("Change app")
                .setMessage(dialogEntry)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    	
                    		((MainActivity) getActivity()).resetText();
                    	
                    }
                })
                .create();
    }

}
